<template>
  <el-dialog :title="this.$i18n.t('groups.groupOrderList')"
             width="60%"
             :close-on-click-modal="false"
             :visible.sync="dialogTableVisible">
    <el-table :data="tableData"
              style="width: 100%">
      <el-table-column prop="orderNumber"
                       :label="this.$i18n.t('order.number')"
                       width="180">
      </el-table-column>
      <el-table-column prop="activityProdPrice"
                       :label="this.$i18n.t('groups.actProductAmount')">
      </el-table-column>
      <el-table-column prop="payPrice"
                       :label="this.$i18n.t('home.payAmount')">
      </el-table-column>
      <el-table-column :label="this.$i18n.t('groups.membership')">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.identityType == 1 && scope.row.userId != 0"
                  size="mini"
                  type="success">{{$t("groups.head")}}</el-tag>
          <el-tag v-if="scope.row.identityType == 0 && scope.row.userId != 0"
                  size="mini">{{$t("groups.member")}}</el-tag>
          <el-tag v-if="scope.row.userId == 0"
                  size="mini"
                  type="info">{{$t("groups.robot")}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="createTime"
                       width="180"
                       :label="this.$i18n.t('order.createTime')">
      </el-table-column>
      <el-table-column :label="this.$i18n.t('text.menu')"
                       width="180">
        <template slot-scope="scope">
          <el-button @click="viewOrder(scope.row.orderNumber)"
                     type="text"
                     size="small"
                     :disabled="scope.row.userId == 0">{{$t("order.viewOrder")}}</el-button>
        </template>
      </el-table-column>
      create_time
    </el-table>
  </el-dialog>
</template>

<script>
export default {
  data () {
    return {
      tableData: null,
      dialogTableVisible: false
    }
  },
  methods: {
    init (groupTeamId) {
      this.dialogTableVisible = true
      this.$nextTick(() => {
        if (groupTeamId) {
          this.$http({
            url: this.$http.adornUrl('/group/team/info/' + groupTeamId),
            method: 'get',
            params: this.$http.adornParams()
          }).then(({ data }) => {
            this.tableData = data
          })
        }
      })
    },
    viewOrder (orderNumber) {
      this.dialogTableVisible = false
      this.$router.push({
        path: '/order-order',
        query: { orderNumber }
      })
    }
  }
}
</script>
